import axios from "~/axios";

// 查询列表
export function tableList(pageIndex, pageSize, roleCode, roleName) {
  return axios.get('/api/admin/acl/role/' + pageIndex + '/' + pageSize, {
    params: {
      roleCode: roleCode,
      roleName: roleName
    }
  });
}

// 通过id查询用户信息
export function getUserInfo(id) {
  return axios.get('/api/admin/acl/role/get/' + id);
}

// 批量删除
export function batchRemove(idList) {
  return axios.post('/api/admin/acl/role/batchRemove', idList);
}

// 新增或修改
export function saveOrUpdate(formData) {
  let url = ''
  if(formData.id === 0) {
    url = 'save'
  } else {
    url = 'update'
  }
  return axios.post('/api/admin/acl/role/' + url, formData);
}

// 查询所有菜单
export function menuAll() {
  return axios.get('/api/admin/acl/permission')
}

// 通过角色ID查询选中的菜单
export function toAssign(roleId) {
  return axios.get('/api/admin/acl/permission/toAssign/' + roleId)
}
